#ifndef __SERVER_H__
#define __SERVER_H__

#include <soar.h>

__BEGIN_DECLS

/*----- 共享信息 -----*/
struct cnfg_info
{/*{{{*/
    char server[NAME_SIZE+1];
    struct
    {
        char location[LONG_FILE_NM_SIZE+1];
        unsigned int tracking;
    } _errlog_;
    struct
    {
        unsigned int server_port;
        unsigned int monitor_port;
    } _access_;
    struct
    {
        char location[LONG_FILE_NM_SIZE+1];
        SQLIC db;
    } _db_;
};/*}}}*/
extern struct cnfg_info cnfg_info;

/*----- 统计信息 -----*/
struct stat_info
{/*{{{*/
    struct
    {
        struct _client_info
        {
            char *ip;
            unsigned int port;
            unsigned int call_num;
        } client[EP_POLL_MAX_NUM];
        int client_num;
        unsigned int conn_served;
    }
    _worker_; 

    struct
    {
        struct _svc_info
        {
            char *name;
            unsigned int call_num;
        } *svc;
    }
    _svc_;
};/*}}}*/
extern struct stat_info stat_info;

/*----- 服务 -----*/
typedef int (*P_SVC_FUNC)(char *, char *);
#define SVC_FUNC(svc)   \
    int SVC_FUNC_##svc(char *request, char *respond)
struct svc_map
{   
    char *name;
    P_SVC_FUNC pfunc;
};      
extern struct svc_map SVC_MAP[];
extern unsigned int SVC_MAP_SIZE;

__END_DECLS

#endif
